package com.zjhome.cloudnote.service.impl;


import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.zjhome.cloudnote.domain.UserInfo;
import com.zjhome.cloudnote.mapper.UserMapper;
import com.zjhome.cloudnote.service.UserService;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper	userMapper;	

	@Override
	public UserInfo selectUserById(String id) throws Exception {
		// 
		return userMapper.selectUserById(id);
	}

	@Override
	public int insertUserByParam(UserInfo user) throws Exception {
		// 生成id 
		if (StringUtils.isEmpty(user.getId())) {			
			user.setId(UUID.randomUUID().toString());
		}
		return userMapper.insertUserByParam(user);
	}

	@Override
	public int updateUserByParam(UserInfo userInfo) throws Exception {
		// 
		return userMapper.updateUserByParam(userInfo);
	}

	@Override
	public int deleteUserById(String id) throws Exception {
		// 
		return userMapper.deleteUserById(id);
	}


}
